class Animal {
    action () {
        console.log('Animal lalk')
    }
}

class Dog extends Animal {
    action () {
        console.log('dog runnig')
    }
}

class Fish extends Animal {
    action () {
        console.log('fish runnig')
    }
}

function makeActions(animals: Animal[]) {
// function makeActions(animals: (Dog | Fish)[]) {
    animals.forEach(item => {
        item.action()
    })
}
makeActions([new Dog(), new Fish()])
//  父类引用指向子类的对象
//  多态的目的是为了写出更加具备通用性的代码
